package com.smzd.projforge.actions;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smzd.core.business.IService;
import com.smzd.core.utils.db.ORPage;
import com.smzd.core.actions.AbstractMeetingOwnedController;
import com.smzd.framework.system.domain.Meeting;
import com.smzd.projforge.business.TemplateService;
import com.smzd.projforge.domain.Template;

@Controller
@RequestMapping("/templates")
public class TemplateController extends AbstractMeetingOwnedController<Template> {
    @Autowired
    private TemplateService service;

    @Override
    protected IService<Template> getService() {
        return service;
    }

    @RequestMapping(value="/add", method=RequestMethod.GET)
    @Override
    public String toAddPage(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        return super.toAddPage(model, elem, result);
    }

    @RequestMapping(value="/add", method=RequestMethod.POST)
    @ResponseBody
    @Override
    public String postAddData(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        return super.postAddData(model, elem, result);
    }

    @RequestMapping(method=RequestMethod.GET)
    @Override
    public String toListPage(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        return super.toListPage(model, elem, result);
    }

    @RequestMapping(value="/list", method=RequestMethod.POST)
    @ResponseBody
    @Override
    public String getListData(Map<String, Object> model,ORPage<Meeting, Template> page,
            BindingResult result) throws Exception {
        return super.getListData(model, page, result);
    }

    @RequestMapping(value="/edit", method=RequestMethod.GET)
    @Override
    public String toEditPage(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        elem = service.getItemById(elem.getId());
        return super.toEditPage(model, elem, result);
    }

    @RequestMapping(value="/edit", method=RequestMethod.POST)
    @ResponseBody
    @Override
    public String postEditData(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        return super.postEditData(model, elem, result);
    }

    @RequestMapping(value="/remove", method=RequestMethod.POST)
    @ResponseBody
    @Override
    public String postRemoveData(Map<String, Object> model, Template elem,
            BindingResult result) throws Exception {
        return super.postRemoveData(model, elem, result);
    }
    
}